package com.sh.rbac.controller;

import com.sh.rbac.result.Result;
import com.sh.rbac.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件控制器
 *
 * @author wb
 * @since 2024-10-01
 */
@RestController
@RequestMapping("file")
public class FileController {

    @Autowired
    private FileService fileService;


    @PostMapping("upload")
    public Result<String> upload(@RequestPart("file") MultipartFile file) {
        return Result.success(fileService.upload(file));
    }

    @GetMapping("download/{filePath}")
    public void download(@PathVariable String filePath) {
        fileService.download(filePath);
    }
}
